package com.fcscs.cservice.ws.client.communicationservice;

import org.apache.commons.codec.binary.Base64;
import org.apache.log4j.Logger;

import com.fcscs.ws.client.BaseInterfaceServiceClient;
import com.fcscs.ws.schemas.communicationservice.SendDataRequest;
import com.fcscs.ws.schemas.communicationservice.SendDataResponse;

public class SendDataClient extends BaseInterfaceServiceClient {

	private static final Logger LOG = Logger.getLogger(SendDataClient.class);

	public SendDataResponse sendData(String propIp, SendDataRequest req) {
    	LOG.info("--------------Sending data...");
    	String data = req.getData();
    	req.setData(new String(Base64.encodeBase64(data.getBytes())));
    	SendDataResponse resp = (SendDataResponse)getWebServiceTemplate().marshalSendAndReceive(genInterfaceURI(propIp), req);
		LOG.info("----------Send Data " + (resp.getSuccess() ? "successful" : "failed"));
		return resp;
	}
}
